<#ftl strip_whitespace=true>
<#macro bind path>
    <#if htmlEscape?exists>
        <#assign status = springMacroRequestContext.getBindStatus(path, htmlEscape)>
    <#else>
        <#assign status = springMacroRequestContext.getBindStatus(path)>
    </#if>
    <#-- assign a temporary value, forcing a string representation for any
    kind of variable. This temp value is only used in this macro lib -->
    <#if status.value?exists && status.value?is_boolean>
        <#assign stringStatusValue=status.value?string>
    <#else>
        <#assign stringStatusValue=status.value?default("")>
    </#if>
</#macro>
<#macro closeTag>
    <#if xhtmlCompliant?exists && xhtmlCompliant>/><#else>></#if>
</#macro>
<#macro showErrors separator classOrStyle="">
    <#list status.errorMessages as error>
    <#if classOrStyle == "">
        <b>${error}</b>
    <#else>
        <#if classOrStyle?index_of(":") == -1><#assign attr="class"><#else><#assign attr="style"></#if>
        <span ${attr}="${classOrStyle}">${error}</span>
    </#if>
    <#if error_has_next>${separator}</#if>
    </#list>
</#macro>
<#macro textfield path name  fieldType="text" attributes="">
    <@bind path/>
	<tr>
		<th><label for="${status.expression}">${name}</label></th>
		<td><input type="${fieldType}" id="${status.expression}" name="${status.expression}" value="<#if fieldType!="password">${stringStatusValue}</#if>" ${attributes}<@closeTag/>
		<@showErrors '','fieldError' /></td>
	</tr>
</#macro>
<#macro grid pager param url>
<#assign len = param?size>
<#assign list = pager.getList()>
	<table>
		<tr>
			<#list param? keys as key>
				<td>${key}</td>
			</#list>			
		</tr>
		<#list list as l>
			<tr>
				<#list param? keys as key>
					<td>${l[param[key]]}</td>
				</#list>
			<tr>	
		</#list>
		<tr>
			<td colspan="${len}" align="right">
				<#if (pager.totalPages>0)>
					<a href="${url}?pager.currentPage=1">首页</a> 
					<#if pager.hasPrev>
							<a href="${url}?pager.currentPage=${pager.currentPage-1 }">上一页</a>
					<#else>
						上一页
					</#if>
					<#if pager.hasNext>
							<a href="${url}?pager.currentPage=${pager.currentPage+1 }">下一页</a>
					<#else>
						下一页
					</#if>
						<a href="${url}?pager.currentPage=${pager.totalPages }">末页</a>
				<#else>
					无相关记录
				</#if>
			</td>
		</tr>
	</table>
	
</#macro>